<h1><?php __('Congressos'); ?></h1>

<div class="actions">
    <ul>
        <li><?php echo $html->link(__('Adicionar Congresso', true), array('action' => 'add')); ?></li>
    </ul>
</div>
<br/>
<br/>
<br/>

<p>
    <?php
    echo $paginator->counter(array(
        'format' => __('Página %page% de %pages%, mostrando %current% registros de %count% no total, do %start% ao %end%', true)
    ));
    ?></p>
<table cellpadding="0" cellspacing="0">
    <tr>
        <th><?php echo $paginator->sort('#', 'number'); ?></th>
        <th width="40%"><?php echo $paginator->sort('Nome', 'name'); ?></th>
        <th style="text-align: center;"><?php echo $paginator->sort('Status', 'status'); ?></th>
        <th style="text-align: center;"><?php echo $paginator->sort('Data de Abertura', 'start_submission_date'); ?></th>
        <th class="actions" colspan="5" style="text-align: center;"><?php __('Ações'); ?></th>
    </tr>
    <?php
    $i = 0;
    foreach ($congresses as $congress):
        $class = null;
        if ($i++ % 2 == 0) {
            $class = ' class="altrow"';
        }
    ?>
        <tr<?php echo $class; ?>>
            <td><?php echo $congress['Congress']['number'] ?></td>
            <td><?php echo $html->link(__($congress['Congress']['name'], true), array('action' => 'view', $congress['Congress']['id'])); ?></td>
            <td style="text-align: center;">
            <?php
            switch ($congress['Congress']['status']):
                case 'A':
                    echo 'Aberto';
                    break;
                case 'S':
                    echo 'Avaliação';
                    break;
                case 'C':
                    echo 'Cancelado';
                    break;
                case 'E':
                    echo 'Encerrado';
                    break;
            endswitch;
            ?>
        </td>
        <td style="text-align: center;"><?php echo date('d/m/Y', strtotime($congress['Congress']['start_submission_date'])); ?>        </td>
        <td class="actions">
            <?php
            if ((date('Y-m-d', strtotime($congress['Congress']['deadline_submission'])) < date('Y-m-d')) && ($congress['Congress']['status'] == 'A')):
                echo $html->link(__('Fim Submissão', true), array('action' => 'finalizeSubmission', $congress['Congress']['id']));
            else:
                echo '<span>Fim Submissão</span>';
            endif;
            ?>
        </td>
        <td class="actions">
            <?php
            if ((date('Y-m-d', strtotime($congress['Congress']['deadline_evaluation'])) < date('Y-m-d')) && ($congress['Congress']['status'] == 'S')):
                echo $html->link(__('Fim Avaliação', true), array('action' => 'finalizeEvaluation', $congress['Congress']['id']));
            else:
                echo '<span>Fim Avaliação</span>';
            endif;
            ?>
        </td>
        <td class="actions">
            <?php
            if ($congress['Congress']['status'] == 'E'):
                echo $html->link(__('Classificação', true), '/articles/finalList/' . $congress['Congress']['id']);
            else:
                echo '<span>Classificação</span>';
            endif;
            ?>
        </td>
    </tr>
    <?php endforeach; ?>
        </table>

        <div class="paging">
    <?php echo $paginator->prev('<< ' . __('anterior', true), array(), null, array('class' => 'disabled')); ?>
            | 	<?php echo $paginator->numbers(); ?>
    <?php echo $paginator->next(__('próxima', true) . ' >>', array(), null, array('class' => 'disabled')); ?>
</div>
